package org.shj.dhsjjg.primarypath;

//把这一个图用邻接表结构表示
public class GraphAdjList {
	private VertexNode[] nodes;
	
	public GraphAdjList(){
		init();
	}
	
	//把 graphAdjList.png 转化为邻接表
	public VertexNode[] init(){
		nodes = new VertexNode[10]; //图中有10个结点
		VertexNode n0 = new VertexNode(0, 0);
		EdgeNode en01 = new EdgeNode(2,4);
		EdgeNode en02 = new EdgeNode(1,3);
		en01.setNext(en02);		
		n0.setFirstEdge(en01);
		nodes[0] = n0;
		
		VertexNode n1 = new VertexNode(1, 1);
		EdgeNode en11 = new EdgeNode(4,6);
		EdgeNode en12 = new EdgeNode(3,5);
		en11.setNext(en12);		
		n1.setFirstEdge(en11);
		nodes[1] = n1;
		
		VertexNode n2 = new VertexNode(1, 2);
		EdgeNode en21 = new EdgeNode(5,7);
		EdgeNode en22 = new EdgeNode(3,8);
		en21.setNext(en22);		
		n2.setFirstEdge(en21);
		nodes[2] = n2;
		
		VertexNode n3 = new VertexNode(2, 3);
		EdgeNode en31 = new EdgeNode(4,3);
		n3.setFirstEdge(en31);
		nodes[3] = n3;
		
		VertexNode n4 = new VertexNode(2, 4);
		EdgeNode en41 = new EdgeNode(7,4);
		EdgeNode en42 = new EdgeNode(6,9);
		en41.setNext(en42);		
		n4.setFirstEdge(en41);
		nodes[4] = n4;
		
		VertexNode n5 = new VertexNode(1, 5);
		EdgeNode en51 = new EdgeNode(7,6);
		n5.setFirstEdge(en51);
		nodes[5] = n5;
		
		VertexNode n6 = new VertexNode(1, 6);
		EdgeNode en61 = new EdgeNode(9,2);
		n6.setFirstEdge(en61);
		nodes[6] = n6;
		
		VertexNode n7 = new VertexNode(2, 7);
		EdgeNode en71 = new EdgeNode(8,5);
		n7.setFirstEdge(en71);
		nodes[7] = n7;
		
		VertexNode n8 = new VertexNode(1, 8);
		EdgeNode en81 = new EdgeNode(9,3);
		n8.setFirstEdge(en81);
		nodes[8] = n8;
		
		VertexNode n9 = new VertexNode(2, 9);
		nodes[9] = n9;
		
		return nodes;
	}
}
